import request from '../utils/request';

// API响应类型
interface ApiResponse<T> {
  code: number;
  msg: string;
  data: T;
  isSuc: boolean;
}

// 箱子类型接口
interface BoxType {
  id: number;
  name: string;
  length: number;
  width: number;
  height: number;
  notes: string;
  status: number;
}

// 分页数据接口
interface PagedData<T> {
  data: T[];
  length: number;
  totalCount: number;
  totalPage: number;
}

// 获取箱子类型列表
export function getBoxTypeList(params: {
  pageIndex?: number;
  pageSize?: number;
  name?: string;
  status?: number;
}): Promise<ApiResponse<PagedData<BoxType>>> {
  return request({
    url: '/api/BoxTypes/GetBoxTypeList',
    method: 'get',
    params
  });
}

// 根据ID获取箱子类型详情
export function getBoxTypeById(id: number): Promise<ApiResponse<BoxType>> {
  return request({
    url: '/api/BoxTypes/GetBoxTypeById',
    method: 'get',
    params: { id }
  });
}

// 创建箱子类型
export function createBoxType(data: {
  id?: number;
  name: string;
  length: number;
  width: number;
  height: number;
  notes: string;
  status: number;
}): Promise<ApiResponse<BoxType>> {
  return request({
    url: '/api/BoxTypes/CreateBoxType',
    method: 'post',
    data
  });
}

// 更新箱子类型
export function updateBoxType(data: {
  id: number;
  name: string;
  length: number;
  width: number;
  height: number;
  notes: string;
  status: number;
}): Promise<ApiResponse<BoxType>> {
  return request({
    url: '/api/BoxTypes/UpdateBoxType',
    method: 'put',
    data
  });
}

// 删除箱子类型
export function deleteBoxType(id: number): Promise<ApiResponse<any>> {
  return request({
    url: '/api/BoxTypes/DeleteBoxType',
    method: 'delete',
    params: { id }
  });
} 